<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">
    <ui:define name="head">
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
        </script>
    </ui:define>
    <ui:define name="content">
        <h:form id="form">
            <p:growl id="msgs" showDetail="true"/>
            <!--<p:focus for="id"/>-->
            <h:panelGrid id="pgCondition" style="width: 100%">
                <h:panelGrid columns="9">
                    <h:outputLabel value="客户编号：" for="id"/>
                    <p:inputText id="id" value="#{custAction.esCust.id}"
                                 readonly="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};"/>
                    <p:commandButton id="autoSetIdBtn" icon="ui-icon-plus"
                                 action="#{custAction.setMaxNoPlusOne}"
                                 update="id"
                                 disabled="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};height:20px">
                    </p:commandButton>
                    <h:outputLabel value="客户名称：" for="name"/>
                    <p:inputText id="name" value="#{custAction.esCust.name}"
                                 readonly="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};"/>
                    <h:outputLabel value="手机：" for="mobilephone"/>
                    <p:inputText id="mobilephone" value="#{custAction.esCust.mobilephone}"
                                 readonly="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};"/>
                    <h:outputLabel value="电话：" for="operphone"/>
                    <p:inputText id="operphone" value="#{custAction.esCust.operphone}"
                                 readonly="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};"/>
                </h:panelGrid>
                <h:panelGrid columns="8">
                    <h:outputLabel value="备注内容：" for="note"/>
                    <p:inputText id="note" value="#{custAction.esCust.note}"
                            style="width:160px;"/>
                    <h:outputLabel value="其他电话：" for="otherphone"/>
                    <p:inputText id="otherphone" value="#{custAction.esCust.otherphone}"
                                 readonly="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};"/>
                    <h:outputLabel value="传真：" for="fax"/>
                    <p:inputText id="fax" value="#{custAction.esCust.fax}"
                                 readonly="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};"/>
                    <h:outputLabel value="邮箱：" for="email"/>
                    <p:inputText id="email" value="#{custAction.esCust.email}"
                                 readonly="#{custAction.styleModel.disabled_Flag}"
                                 style="#{custAction.styleModel.disabled_Style};"/>
                </h:panelGrid>
                <h:panelGrid columns="4">
                    <p:commandButton id="qryBtn" value="查询"
                                     action="#{custAction.onQueryAction}"
                                     update="pdt,msgs">
                    </p:commandButton>
                    <p:commandButton id="resetBtn" value="重置"
                                     action="#{custAction.resetAction}"
                                     update="pgCondition,msgs">
                    </p:commandButton>
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="/images/ajaxloading.gif"/>
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value=""/>
                        </f:facet>
                    </p:ajaxStatus>
                    <p:commandButton id="submitBtn"
                                     value="#{custAction.strSubmitType eq 'Add'?'提交（增加）':
                                               custAction.strSubmitType eq 'Upd'?'提交（更新）':
                                               custAction.strSubmitType eq 'Del'?'提交（删除）':'提交'}"
                                     action="#{custAction.submitThisRecordAction}"
                                     update="pdt,msgs">
                    </p:commandButton>
                </h:panelGrid>
            </h:panelGrid>
            <p:contextMenu for="pdt">
                <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                            actionListener="#{custAction.selectRecordAction('Upd')}" update="pdt,msgs,pgCondition">
                </p:menuitem>
                <p:menuitem value="删除" icon="ui-icon-close"
                            actionListener="#{custAction.selectRecordAction('Del')}" update="pdt,msgs,pgCondition">
                </p:menuitem>
            </p:contextMenu>
            <p:dataTable id="pdt" style="width:100%;"
                         value="#{custAction.listInitCust}"
                         var="record"
                         rowKey="#{record.pkid}"
                         selection="#{custAction.esCustSelected}"
                         selectionMode="single"
                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
                         {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         paginator="true"
                         paginatorPosition="bottom"
                         rows="15"
                         rowsPerPageTemplate="200,100,50,40,30,20,15"
                         emptyMessage="数据记录为空..."
                         scrollable="true"
                         scrollHeight="370">
                <p:column headerText="pkid" style="display:none;" rendered="false">
                    <h:outputText id="tetid" style="display:none;" rendered="false" value="#{record.pkid}"/>
                </p:column>
                <p:column headerText="客户编号" style="width:160px;text-align:center">
                    <h:outputText value="#{record.id}"/>
                </p:column>
                <p:column headerText="客户名称" style="width:300px;text-align:left">
                    <h:outputText value="#{record.name}"/>
                </p:column>
                <p:column headerText="手机" style="width:80px;text-align:center">
                    <h:outputText value="#{record.mobilephone}"/>
                </p:column>
                <p:column headerText="邮箱" style="width:150px;text-align:center">
                    <h:outputText value="#{record.email}"/>
                </p:column>
                <p:column headerText="电话" style="width:100px;text-align:center">
                    <h:outputText value="#{record.operphone}"/>
                </p:column>
                <p:column headerText="其他电话" style="width:100px;text-align:center">
                    <h:outputText value="#{record.otherphone}"/>
                </p:column>
                <p:column headerText="传真" style="width:100px;text-align:center">
                    <h:outputText value="#{record.fax}"/>
                </p:column>
                <p:column headerText="备注内容" style="width:150px;text-align:center">
                    <h:outputText value="#{record.note}"/>
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:define>
</ui:composition>